#ifndef STX_LOG_HPP
#define STX_LOG_HPP

#include <stx/core.hpp>
#include <stx/log/abstract_logger.hpp>
#include <stx/log/basic_logger.hpp>
#include <stx/log/ostream_logger.hpp>
#include <stx/log/file_logger.hpp>
#include <stx/log/rolling_file_logger.hpp>
#include <stx/log/syslog_logger.hpp>
#include <stx/log/global_logger.hpp>

//  Log level constants are defined in <stx/log/basic_logger.hpp> file.
//  Available ready-to-use logger classes:
//      class cout_logger;
//      class clog_logger;
//      class file_logger;
//      class rolling_file_logger;
//      class syslog_logger;

//  These functions - get_logger() and set_logger() - should _not_ be in namespace stx,
//  in order to let users provide their own implementations inside their classes to
//  override default log facilities.
inline stx::basic_logger* get_logger()
{
    return stx::global_logger<stx::basic_logger>();
}

inline void set_logger(stx::basic_logger* log)
{
    stx::global_logger<stx::basic_logger>(log);
}

//  More convenient macros without STX_ prefix are defined in file <stx/log/enable_short_macros.hpp>:
//      LOG_TRACE
//      LOG_DEBUG
//      LOG_INFO
//      LOG_WARN
//      LOG_ERROR
//      LOG_FATAL
//  They are not included by default in order to avoid possible conflicts with user-defined macros.
//  You should include <stx/log/enable_short_macros.hpp> by yourself.

#define STX_LOG_TRACE(x) get_logger()->trace() << x
#define STX_LOG_DEBUG(x) get_logger()->debug() << x
#define STX_LOG_INFO(x)  get_logger()->info()  << x
#define STX_LOG_WARN(x)  get_logger()->warn()  << x
#define STX_LOG_ERROR(x) get_logger()->error() << x
#define STX_LOG_FATAL(x) get_logger()->fatal() << x

#endif // STX_LOG_HPP
